using System;

namespace PathX
{
    public static class Ensure
    {
        public static void ArgumentNotNullOrEmpty([Ensure.ValidatedNotNull] string value, string variableName)
        {
            if (string.IsNullOrEmpty(value))
                throw new ArgumentException("Cannot be null or empty!", variableName);
        }
        
        public static void ArgumentNotNull([Ensure.ValidatedNotNull] object value, string variableName)
        {
            if (value == null)
                throw new ArgumentNullException(variableName);
        }
        
        public static void ArgumentInRange(
            Func<bool> check,
            string variableName,
            object value,
            string message = null)
        {
            if (!check())
                throw new ArgumentException(message, variableName);
        }

        /// <summary>Attribute to satisfy the CA1062 rule</summary>
        private sealed class ValidatedNotNullAttribute : Attribute
        {
        }
    }
}